home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / ddj0897.zip / RCSC.ZIP / PACKAGES / AWK320.ZIP / FACT.AWK < prev    next >
Text File  |  1990-06-04  |  197b  |  12 lines

  1. # calculate and print the factorial of the input
  2.  
  3. function factorial(n) {
  4.     if (n <= 1)
  5.         return 1
  6.     else
  7.         return n * factorial(n - 1)
  8. }
  9. {
  10.     print $1, factorial($1)
  11. }
  12.